package demo_0414;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class CharacterCopy {
    public static void main(String[] args) {
        FileReader fr = null;
        FileWriter fw = null;
        try {
            fr = new FileReader("in.txt");
            fw = new FileWriter("out.txt");
            int c;
            while ((c = fr.read()) != -1) {
                fw.write(c);
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }   catch (IOException e) {
            throw new RuntimeException(e);
        }   finally {
            if (fr!= null) {
                try {
                    fr.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            if (fw!= null) {
                try {
                    fw.close();
                }   catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
